.. _`Polynomial Features`: .. _`org.sysess.sympathy.machinelearning.polynomial_features`: Polynomial Features ``````````````````` .. image:: polynomial.svg :width: 48 Generate polynomial and interaction features. Documentation ::::::::::::: Generate a new feature matrix consisting of all polynomial combinations of the features with degree less than or equal to the specified degree. For example, if an input sample is two dimensional and of the form [a, b], the degree-2 polynomial features are [1, a, b, a^2, ab, b^2]. Often it's useful to add complexity to a model by also considering nonlinear features of the input data. This can enhance the predictive power of the model. Attributes ========== **n_input_features_** **n_output_features_** **powers_** Definition :::::::::: Output ports ============ **model** | Type: model | Description: Model Configuration ============= **Degree** (degree) If a single int is given, it specifies the maximal degree of the polynomial features. If a tuple `(min_degree, max_degree)` is passed, then `min_degree` is the minimum and `max_degree` is the maximum polynomial degree of the generated features. Note that `min_degree=0` and `min_degree=1` are equivalent as outputting the degree zero term is determined by `include_bias`. **Include bias** (include_bias) If `True` (default), then include a bias column, the feature in which all polynomial powers are zero (i.e. a column of ones - acts as an intercept term in a linear model). **Only interaction features produced** (interaction_only) If `True`, only interaction features are produced: features that are products of at most `degree` *distinct* input features, i.e. terms with power of 2 or higher of the same input feature are excluded: - included: `x`, `x`, `x * x`, etc. - excluded: `x ** 2`, `x ** 2 * x`, etc. Examples ======== The node can be found in: * :download:`Polynomial_Features.syx ` Implementation ============== .. automodule:: node_preprocessing :noindex: .. class:: PolynomialFeatures :noindex: